-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore non-explicit NEVER in purity check #3243
Conversation
src/Analyser/NodeScopeResolver.php
Outdated
if ($exprType->isCallable()->yes()) { | ||
if ( | ||
$exprType->isCallable()->yes() | ||
&& (!$exprType instanceof NeverType || $exprType->isExplicit()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a different way to fix this would be to make NeverType
return a different acceptor on getCallableParametersAcceptors
when non-explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would make more sense to me. It's basically never going to be called so a special class instead of TrivialParametersAcceptor would be welcome. It's pure, and probably also returns NeverType?
src/Analyser/NodeScopeResolver.php
Outdated
if ($exprType->isCallable()->yes()) { | ||
if ( | ||
$exprType->isCallable()->yes() | ||
&& (!$exprType instanceof NeverType || $exprType->isExplicit()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would make more sense to me. It's basically never going to be called so a special class instead of TrivialParametersAcceptor would be welcome. It's pure, and probably also returns NeverType?
Well, or NeverType doesn't have to return yes for isCallable, I'm not sure why it does. |
This pull request has been marked as ready for review. |
public function testBug11207b(): void | ||
{ | ||
$this->treatPhpDocTypesAsCertain = true; | ||
$this->analyse([__DIR__ . '/data/bug-11207.php'], []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of pattern is usually done via a dataProvider.
Thank you. |
closes phpstan/phpstan#11207